package com.whz.gateway.common;

import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ResourceBundleMessageSource;

import java.nio.charset.StandardCharsets;

/**
 * @author whz
 * @date 2021/9/14
 */
public class GatewayMessageAccessor extends ResourceBundleMessageSource {
    public GatewayMessageAccessor() {
        setBasename("gateway_message");
        setDefaultEncoding(StandardCharsets.UTF_8.name());
    }

    public static MessageSourceAccessor getAccessor() {
        return new MessageSourceAccessor(new GatewayMessageAccessor());
    }

    public static String getMessage(final String code) {
        return getAccessor().getMessage(code);
    }

    public static String getMessage(final String code, final Object... args) {
        return getAccessor().getMessage(code, args);
    }
}